package com.hg.concurent.demo10;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: skh
 * @Date: 2020/1/3 15:41
 * @Description:
 */
public class ThreadUtilDemo {

    static AtomicInteger i = new AtomicInteger(0);

    public static void main(String[] args) {
        //模拟1000个请求同时并发
        ThreadUtil.concurrencyTest(10000, new Runnable() {
            @Override
            public void run() {
                    test();
            }
        });

        System.out.println("i = " + i.get());

    }

    public static void test() {
        ThreadUtil.sleep(300);
        i.incrementAndGet();
    }
}
